package BanqueGestion;

/**
 * Interface definition: Banque.
 * 
 * @author OpenORB Compiler
 */
public class _BanqueStub extends org.omg.CORBA.portable.ObjectImpl
        implements Banque
{
    static final String[] _ids_list =
    {
        "IDL:BanqueGestion/Banque:1.0"
    };

    public String[] _ids()
    {
     return _ids_list;
    }

    private final static Class _opsClass = BanqueGestion.BanqueOperations.class;

    /**
     * Operation creerCompte
     */
    public boolean creerCompte(String nomProprietaire, int numCompte)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("creerCompte",true);
                    _output.write_string(nomProprietaire);
                    _output.write_long(numCompte);
                    _input = this._invoke(_output);
                    boolean _arg_ret = _input.read_boolean();
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("creerCompte",_opsClass);
                if (_so == null)
                   continue;
                BanqueGestion.BanqueOperations _self = (BanqueGestion.BanqueOperations) _so.servant;
                try
                {
                    return _self.creerCompte( nomProprietaire,  numCompte);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation supprimerCompte
     */
    public void supprimerCompte(int numCompte)
        throws BanqueGestion.BanquePackage.UnknownAccount
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("supprimerCompte",true);
                    _output.write_long(numCompte);
                    _input = this._invoke(_output);
                    return;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    if (_exception_id.equals(BanqueGestion.BanquePackage.UnknownAccountHelper.id()))
                    {
                        throw BanqueGestion.BanquePackage.UnknownAccountHelper.read(_exception.getInputStream());
                    }

                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("supprimerCompte",_opsClass);
                if (_so == null)
                   continue;
                BanqueGestion.BanqueOperations _self = (BanqueGestion.BanqueOperations) _so.servant;
                try
                {
                    _self.supprimerCompte( numCompte);
                    return;
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation rechercheCompte
     */
    public BanqueGestion.CompteBancaire rechercheCompte(int numCompte)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("rechercheCompte",true);
                    _output.write_long(numCompte);
                    _input = this._invoke(_output);
                    BanqueGestion.CompteBancaire _arg_ret = BanqueGestion.CompteBancaireHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("rechercheCompte",_opsClass);
                if (_so == null)
                   continue;
                BanqueGestion.BanqueOperations _self = (BanqueGestion.BanqueOperations) _so.servant;
                try
                {
                    return _self.rechercheCompte( numCompte);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation listCompte
     */
    public BanqueGestion.CompteBancaire[] listCompte(String nomProprietaire)
        throws BanqueGestion.BanquePackage.InvalidAccountName
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("listCompte",true);
                    _output.write_string(nomProprietaire);
                    _input = this._invoke(_output);
                    BanqueGestion.CompteBancaire[] _arg_ret = BanqueGestion.listeComptesHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    if (_exception_id.equals(BanqueGestion.BanquePackage.InvalidAccountNameHelper.id()))
                    {
                        throw BanqueGestion.BanquePackage.InvalidAccountNameHelper.read(_exception.getInputStream());
                    }

                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("listCompte",_opsClass);
                if (_so == null)
                   continue;
                BanqueGestion.BanqueOperations _self = (BanqueGestion.BanqueOperations) _so.servant;
                try
                {
                    return _self.listCompte( nomProprietaire);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

}
